package edu.mercer.medapps.documentbldr;

import static com.google.common.base.Preconditions.checkNotNull;


/**
 * Demonstration of Document creation using Builder pattern.<p>
 * 
 * Requires a DocumentBuilder for instance.<p>
 * 
 * The DocumentBuilder provides populated DocumentProperties, elements of which 
 * are set with chained method calls.<p>
 * 
 * @see Document
 */

public class DocumentDemo implements Document<DocumentProperties>
{
	private DocumentProperties _documentProperties = new DocumentProperties();
	
	
	public DocumentDemo(final DocumentCreation <DocumentBuilder,
												DocumentProperties, 
												ValidFile> builderIn)
	{
		super();
		
		checkNotNull(builderIn, "null detected builderIn argument");

		_documentProperties = builderIn.properties();
		
	}//constructor

	
	@Fulfills("Document")
	public DocumentProperties properties(){ return _documentProperties; }
		
	
	/** 
	 * Builder static factory method.<p>
	 * 
	 * Omitted from interface since static.<p>
	 * 
	 * @return DocumentBuilder - new instance of builder for creating Document 
	 * instances
	 * 
	 * @see DocumentBuilder
	 */
	
	public static DocumentBuilder builder()
	{ 
		return new DocumentBuilder(); 
		
	}//method
	
	
}//class


